package com.car.dao;

import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.SQLException;

import com.car.entity.AutoHomeEntity;
import com.car.entity.AutoIowmEntity;
import com.car.util.ConnectionPool;

public class AutoHomeDao {
	public boolean addCarInfo(AutoHomeEntity car) {

		Connection conn = ConnectionPool.getConnection();
		PreparedStatement ps = null;
		String sql = "insert into core_brand_autohome(autohome_bbsid,autohome_ppmc,autohome_cxpp,autohome_kbid,autohome_carid) values(?,?,?,?,?)";
		boolean isInsert = false;
		try {
			ps = conn.prepareStatement(sql);
			ps.setString(2, car.getCarBrand());
			ps.setString(5, car.getCarId());
			ps.setString(3, car.getCarName());
			ps.setString(1, car.getBbsId());
			ps.setString(4, car.getIwomId());
			isInsert = ps.execute();
		} catch (SQLException e) {
			e.printStackTrace();
		} finally {
			ConnectionPool.close(ps, conn);
		}
		return isInsert;

	}

	public boolean addCarIowm(AutoIowmEntity kb) {
		System.out.println("into addcariowm");
		boolean isInsert = false;

		Connection conn = ConnectionPool.getConnection();
		PreparedStatement ps = null;
		String sql = "INSERT INTO qczj_kb(kb_id, kb_ppid, kb_cxid, kb_yhmc, kb_yhid, kb_plrq, kb_gmdd, kb_gmqy, kb_jxs, kb_kj,kb_dl, kb_ck, kb_yh, kb_ssx, kb_wg, kb_ns, kb_xjb, kb_plnr, kb_plcd, kb_gmsj, kb_gmjg, kb_syyh,kb_lc, kb_zcs, kb_lls, kb_pls, kb_ztsl, kb_zqsj) VALUES(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)";
		try {
			ps = conn.prepareStatement(sql);
			ps.setInt(1, kb.getKb_id());
			ps.setInt(2, kb.getKb_ppid());
			ps.setInt(3, kb.getKb_cxid());
			ps.setString(4, kb.getKb_yhmc());
			ps.setInt(5, kb.getKb_yhid());
			ps.setDate(6, kb.getKb_plrq());
			ps.setString(7, kb.getKb_gmdd());
			ps.setString(8, kb.getKb_gmqy());
			ps.setString(9, kb.getKb_jxs());
			ps.setFloat(10, kb.getKb_kj());
			ps.setFloat(11, kb.getKb_dl());
			ps.setFloat(12, kb.getKb_ck());
			ps.setFloat(13, kb.getKb_yh());
			ps.setFloat(14, kb.getKb_ssx());
			ps.setFloat(15, kb.getKb_wg());
			ps.setFloat(16, kb.getKb_ns());
			ps.setFloat(17, kb.getKb_xjb());
			ps.setString(18, kb.getKb_plnr());
			ps.setInt(19, kb.getKb_plcd());
			ps.setDate(20, kb.getKb_gmsj());
			ps.setFloat(21, kb.getKb_gmjg());
			ps.setFloat(22, kb.getKb_syyh());
			ps.setInt(23, kb.getKb_lc());
			ps.setInt(24, kb.getKb_zcs());
			ps.setInt(25, kb.getKb_lls());
			ps.setInt(26, kb.getKb_pls());
			ps.setInt(27, kb.getKb_ztsl());
			ps.setDate(28, kb.getKb_zqsj());
			System.out.println("insert kbps:" + ps);
			isInsert = ps.execute();

		} catch (SQLException e) {
			e.printStackTrace();

		} finally {
			ConnectionPool.close(ps, conn);
		}
		// System.out.println(kb.getKb_id());
		return isInsert;

	}
	
	
}
